// CtlWord.cpp : implementation file
//

#include "stdafx.h"
#include "bdc.h"
#include "CtlWord.h"

using namespace bdc::ctl;

// CtlWord

IMPLEMENT_DYNAMIC(CtlWord, CWnd)

CtlWord::CtlWord()
{

}

CtlWord::~CtlWord()
{
}


BEGIN_MESSAGE_MAP(CtlWord, CWnd)
	ON_WM_PAINT()
	ON_WM_CREATE()
END_MESSAGE_MAP()



// CtlWord message handlers




void CtlWord::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: Add your message handler code here
	// Do not call CWnd::OnPaint() for painting messages

	RECT rect;
	GetClientRect(&rect);

	Gdiplus::Graphics graphics(dc.GetSafeHdc());
	Gdiplus::Rect bgRect(0, 0, RMB_WORD_WIDTH, RMB_WORD_HEIGHT);
	graphics.DrawImage(pImgBg, bgRect);
}


int CtlWord::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  Add your specialized creation code here
	HINSTANCE hInst = ((CbdcApp*) AfxGetApp())->hPicResource;
	pImgBg = bdc::LoadPng(hInst, IDB_REMEMBER_WORD);

	RECT memoRect = {CWORD_MEMO_RECT_LEFT + 5, CWORD_MEMO_RECT_TOP + 5, CWORD_MEMO_RECT_RIGHT - 5, CWORD_MEMO_RECT_BOTTOM - 5};
	ctlMemo.Create(_T(""), WS_CHILD | WS_VISIBLE, memoRect, this, 0);

	RECT descRect = {CWORD_DESC_RECT_LEFT + 5, CWORD_DESC_RECT_TOP + 5, CWORD_DESC_RECT_RIGHT - 5, CWORD_DESC_RECT_BOTTOM - 5};
	ctlDesc.Create(_T(""), WS_CHILD | WS_VISIBLE, descRect, this, 0);

	return 0;
}

void CtlWord::setRecord(RecordInfo* info)
{
	pRecordInfo = info;
	ctlDesc.SetWindowText(info->description);
	ctlMemo.SetWindowText(_T(""));
}

void CtlWord::showMemory()
{ 
	ctlMemo.SetWindowText(pRecordInfo->memory);
}
